package com.example.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.data.request.ReqClassesList;
import com.example.data.response.RespClassesInfo;
import com.example.entity.Classes;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * Author:yanghua
 * Date:2023/10/7 10:04
 */
@Mapper
public interface ClassesDao extends BaseMapper<Classes> {
    @Select("select * from classes where del = 0")
    List<Classes> getAllClasses();

    List<RespClassesInfo> getClassesList(ReqClassesList reqClassesList);

    Integer getClassesNumber(ReqClassesList reqClassesList);

    @Update("update classes set del = 1 where id = #{id}")
    Integer deleteClassById(Long id);

    @Select("select c.*, p.profession from classes as c, profession as p where c.del = 0 and c.id = #{id} and c.profession_id = p.id ")
    RespClassesInfo getClassById(Long id);
}
